package com.hh.ui.activity;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import com.hh.droid.R;

/**
 * Created by benhadjahameda on 05/01/2015.
 */
public class UiActMaterialDesign extends ActionBarActivity {

    private boolean _loaded;
    private Toolbar _mToolbar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    @Override
    protected void onStart() {
        super.onStart();
        if(!_loaded)
            initViews();
    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        _loaded=false;
    }
    private void initViews() {

        /**
         * Il faut mettre un tools Bar avec un ID myToolBare
         */
        _mToolbar= (Toolbar) findViewById(R.id.myToolBare);
        if (_mToolbar != null) {
            setSupportActionBar(_mToolbar);
            _mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    return onOptionsItemSelected(item);
                }
            });
        }
        _loaded=true;
    }

    public Toolbar getToolBar(){
        return _mToolbar;
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        return super.onOptionsItemSelected(item);
    }

}
